<!--
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-06-18 16:21:26
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-18 11:36:22
 * @FilePath: \linePatrol\vue-element-plus-admin\src\views\Emergency\components\Detail.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup lang="tsx">
import { PropType } from 'vue'
import { Descriptions } from '@/components/Descriptions'
import { useDictStore } from '@/store/modules/dictData'
import { ElImage } from 'element-plus'
const PATH_URL = import.meta.env.VITE_API_PHOTO_PATH
const props = defineProps({
  currentRow: {
    type: Object as PropType<Nullable<any>>,
    default: () => null
  }
})
const DictStore = useDictStore()
const DetailSchema = [
  {
    field: 'gasdevType',
    label: '燃气设备类型'
  },
  {
    field: 'isInstall',
    label: '是否安装',
    slots: {
      default: (data: any) => {
        return DictStore.$state.secur_y_n?.map((item) => {
          if (item.dictValue == data.isInstall) {
            return item.dictLabel
          }
        })
      }
    }
  },
  {
    field: 'isExpire',
    label: '是否过期',
    slots: {
      default: (data: any) => {
        return DictStore.$state.secur_y_n?.map((item) => {
          if (item.dictValue == data.isExpire) {
            return item.dictLabel
          }
        })
      }
    }
  },
  {
    field: 'installDate',
    label: '安装日期'
  },
  {
    field: 'useAge',
    label: '使用年限'
  },
  {
    field: 'brand',
    label: '品牌'
  },
  {
    field: 'mountPos',
    label: '安装位置',
    slots: {
      default: (data: any) => {
        return DictStore.$state.secur_mount_pos?.map((item) => {
          if (item.dictValue == data.mountPos) {
            return item.dictLabel
          }
        })
      }
    }
  },
  {
    field: 'devState',
    label: '设备状态',
    slots: {
      default: (data: any) => {
        return DictStore.$state.secur_dev_state?.map((item) => {
          if (item.dictValue == data.devState) {
            return item.dictLabel
          }
        })
      }
    }
  },
  {
    field: 'remark',
    label: '描述'
  },
  {
    field: 'file',
    label: '附件',
    slots: {
      default: (data: any) => {
        const res = data.file ? JSON.parse(data.file) : []
        return res?.map((item: string) => {
          return (
            <ElImage
              style="width: 70px; height: 70px;margin-left:10px"
              src={PATH_URL + item}
              preview-src-list={[PATH_URL + item]}
              fit="cover"
            />
          )
        })
      }
    }
  }
]
const Value1 = [
  {
    field: 'whCategory',
    label: '热水器分类',
    slots: {
      default: (data: any) => {
        return DictStore.$state.secur_wh_category?.map((item) => {
          if (item.dictValue == data.whCategory) {
            return item.dictLabel
          }
        })
      }
    }
  }
]
const Value2 = [
  {
    field: 'scCategory',
    label: '灶具分类',
    slots: {
      default: (data: any) => {
        return DictStore.$state.secur_sc_category?.map((item) => {
          if (item.dictValue == data.scCategory) {
            return item.dictLabel
          }
        })
      }
    }
  }
]
const Value3 = [
  {
    field: 'alarmNo',
    label: '报警器编号'
  },
  {
    field: 'alarmCategory',
    label: '报警器分类',
    slots: {
      default: (data: any) => {
        return DictStore.$state.secur_alarm_category?.map((item) => {
          if (item.dictValue == data.alarmCategory) {
            return item.dictLabel
          }
        })
      }
    }
  }
]
const Value4 = [
  {
    field: 'pipeLength',
    label: '管长'
  },
  {
    field: 'pipeJointStyle',
    label: '管接头方式'
  }
]
let Schema: any = []
if (props.currentRow.gasdevType == '热水器') {
  Schema = [...DetailSchema, ...Value1]
} else if (props.currentRow.gasdevType == '燃气灶') {
  Schema = [...DetailSchema, ...Value2]
} else if (props.currentRow.gasdevType == '报警器') {
  Schema = [...DetailSchema, ...Value3]
} else if (props.currentRow.gasdevType == '波纹管') {
  Schema = [...DetailSchema, ...Value4]
} else {
  Schema = DetailSchema
}
</script>

<template>
  <Descriptions :schema="Schema" :data="currentRow" />
</template>
<style scoped></style>
